
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2375. -- 疯狂的涂色 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2375: 疯狂的涂色</h2><span class=green>Time Limit: </span>5 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>92&nbsp;&nbsp;<span class=green>Solved: </span>28<br>[<a href='submitpage.php?id=2375'>Submit</a>][<a href='problemstatus.php?id=2375'>Status</a>][<a href='bbs.php?id=2375'>Discuss</a>]</center><h2>Description</h2><div class=content><div style="text-indent: 21.75pt">小t非常喜爱画画，但是他还是一个初学者。他最近费尽千辛万苦才拜到已仙逝的达芬奇为师（神仙？妖怪？谢谢）。达芬奇果然是画鸡蛋长大的，让小t一入门就拿着一张白纸条疯狂地涂色。假设纸条被划分成了n个区域，用1~n的整数从左到右顺序编号，达芬奇总共下达了m条指令。第I条指令是让小t把编号为(I*p+q)mod n+1与(I*q+p)mod n+1(p,q为常整数)之间的区域（连续的一段区域）涂成第I种颜色。你可以假设达芬奇家中颜料的颜色数足够多（达芬奇是画鸡蛋长大的）。</div>
<div style="text-indent: 21.75pt">现在由于达芬奇下达的指令过多，小t一时应付不过来。达芬奇只让他回答每一个区域最后的颜色。趁达芬奇还在&ldquo;五谷轮回之所&rdquo;忙碌时，小t偷偷的请让你这个计算机高手帮他算出最后的颜色状态，并告诉他。时间紧迫，要快哟！（达芬奇的指令次数多到恶心）</div>
<div>&nbsp;</div></div><h2>Input</h2><div class=content><div style="page-break-after: auto; line-height: normal">&nbsp;</div>
<div style="text-indent: 21.75pt">文件仅一行，为四个整数n,m,p,q。</div>
<div>&nbsp;</div></div><h2>Output</h2><div class=content><div style="text-indent: 21.75pt">文件共n行，第I行代表最后第I个格子的颜色。白色编号为0。</div>
<div>&nbsp;</div></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>4 3 2 4<br />
 <br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>2<br />
3<br />
2<br />
0<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p>&nbsp;20%数据满足：1&le;n&le;1000，1&le;m&le;10000；<br /><br />
40%数据满足：1&le;n&le;10000，1&le;m&le;100000；<br /><br />
100%数据满足：1&le;n&le;1000000，1&le;m&le;10000000;1&le;m*p+q，m*q+p&le;231-1；<br /><br />
&nbsp;<br /><br />
友情提示：<br /><br />
加入编译开关{$M 100000000,0,100000000}，可防栈溢出。</p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search='></a></p></div><center>[<a href='submitpage.php?id=2375'>Submit</a>][<a href='problemstatus.php?id=2375'>Status</a>][<a href='bbs.php?id=2375'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
